BigDFT.Fragments module
This module contains data structures for describing fragments. Fragments are orders lists of atoms.
- distance(i, j, cell=None)[source]
Distance between fragments, defined as distance between centroids (bohr).
- Parameters:
i (Fragment) – first fragment.
j (Fragment) – second fragment.
cell (BigDFT.UnitCells.UnitCell) – unit cell these fragments exist in.
- Returns:
the distance between centroids.
- Return type:
(float)
- pairwise_distance(i, j, cell=None)[source]
Distance between fragments as defined by their two nearest atoms (bohr).
- Parameters:
i (Fragment) – first fragment.
j (Fragment) – second fragment.
cell (BigDFT.UnitCells.UnitCell) – unit cell these fragments exist in.
- Returns:
the pairwise distance between fragments.
- Return type:
(float)
- lineup_fragment(frag)[source]
Align the principal axis of inertia of the fragments along the coordinate axis. Also shift the fragment such as its centroid is zero.
- Parameters:
(BigDFT.Fragments.Fragment) – the fragment to transform.
- Returns:
the transformed fragment.
- Return type:
- class RotoTranslation(frag1, frag2)[source]
Define a transformation which can be applied to a fragment. This rotation is defined by giving this class two fragments, and the rototranslation between those fragments is automatically computed.
- Parameters:
frag1 (BigDFT.Fragments.Fragment) – the first position.
frag2 (BigDFT.Fragments.Fragment) – the second position.
- dot(frag)[source]
Apply the rototranslations on a fragment.
- Parameters:
frag (BigDFT.Fragments.Fragment) – the fragment to rototranslate.
- Returns:
the rototranslated fragment.
- Return type:
- class Translation(t)[source]
This class defines a simple translation.
- Parameters:
t (list) – the vector describing the translation.
- class Rotation(R)[source]
This class defines a simple rotation.
- Parameters:
t (list) – the vector describing the rotation.
- interpolate_fragments(A, B, steps, extrapolation_steps=0)[source]
Given two fragments A and B, this generates a list of Fragments that interpolate between A and B in a specified number of steps.
- Parameters:
A (BigDFT.Fragments.Fragment) – starting fragment.
B (BigDFT.Fragments.Fragment) – ending fragment.
steps (int) – the number of steps to take between A and B.
extrapolation_steps (int) – optionally, we can extrapolate a number of steps beyond B on the same trajectory.
- Returns:
a list of fragments interpolating between A and B including A and B.
- Return type:
(list)
- class Fragment(atomlist=None, xyzfile=None, posinp=None, astruct=None, system=None)[source]
A fragment is a list of atoms in a system. Fragment might have quantities associated to it, like its electrostatic multipoles (charge, dipole, etc.) and also geometrical information (centroids, principla axis etc.). A Fragment might also be rototranslated and combined with other moieteies to form a
BigDFT.Systems.Systems
.- Parameters:
atomlist (list) – list of atomic dictionaries defining the fragment
xyzfile (BigDFT.IO.XYZReader) – an XYZ file to read from.
posinp (dict) – the posinp style dictionary from a logfile/input file.
astruct (dict) – a BigDFT atomic structure style dictionary.
system (BigDFT.Systems.System) – a BigDFT system, esssentially this reduces many fragments into a single fragment.
Todo
Define and describe if this API is also suitable for solid-state fragments
- serialize(name, units='bohr')[source]
Transform the fragment in a list that can be employed for the construction of dataframes or pandas series.
- property centroid
The center of a fragment. Returned in bohr and without regard to unit cell.
- get_centroid(cell=None, units='bohr')[source]
The center of a fragment, with options for units and UnitCell.
- Parameters:
cell (BigDFT.UnitCells.UnitCell) – the cell this fragment is contained in. Minimum image convention will be enforced.
units (str) – units of the centroid to be returned.
- center_of_charge()[source]
The charge center which depends both on the position and net charge of each atom.
- property q0
Provides the global monopole of the fragments given as a sum of the monopoles of the atoms.
- d0(center=None)[source]
Fragment dipole, calculated only from the atomic charges.
- Parameters:
center (list) – the center of charge of the fragment. If this is not present, the centroid is used.
- d1(center=None)[source]
Fragment dipole including the atomic dipoles.
- Parameters:
center (list) – the center of charge of the fragment. If this is not present, the centroid is used.
- get_external_potential(units='bohr', charge_offset=False)[source]
Transform the fragment information into a dictionary ready to be put as an external potential.
- get_net_force()[source]
Returns the net force on a fragment in Ha/Bohr.
- Returns:
(list) Three values which describe the net force.
- property nel
The number of valence electrons of the atoms of the fragment
- rotate_on_axis(angle, axis, centroid=None, units='radians')[source]
Rotate a fragment along a specific axis.
- Parameters:
angle (float) – angle to rotate along the axis.
axis (list) – a list of floats defining the vector to rotate along.
centroid (lismatt) – a list of floats defining the center from which the axis comes out. If not specified, we pick the centroid of the fragment.
units (str) – either radians or degrees.
- translate(vec)[source]
Translate the fragment along the vector provided.
- Parameters:
vec (list) – a list of x, y, z values describing the translation (AU).
- _example()[source]
The following is an example of module usage:
"""Example of using fragments""" from BigDFT.IO import XYZReader, XYZWriter from copy import deepcopy safe_print("Read in an xyz file and build from a list.") atom_list = [] with XYZReader("SiO") as reader: for at in reader: atom_list.append(at) frag1 = Fragment(atomlist=atom_list) for at in frag1: safe_print(at.sym, at.get_position()) safe_print("Centroid", frag1.centroid) safe_print() safe_print("Build from an xyz file directly.") reader = XYZReader("Si4") frag2 = Fragment(xyzfile=reader) for at in frag2: safe_print(at.sym, at.get_position()) safe_print() safe_print("We can combine two fragments with +=") frag3 = deepcopy(frag1) frag3 += frag2 for at in frag3: safe_print(at.sym, at.get_position()) safe_print("Length of frag3", len(frag3)) safe_print() safe_print("Since we can iterate easily, we can also write easily.") with XYZWriter("test.xyz", len(frag3), "angstroem") as writer: for at in frag3: writer.write(at) with open("test.xyz") as ifile: for line in ifile: safe_print(line) safe_print() safe_print("We can also extract using the indices") safe_print(dict(frag3[0])) sub_frag = frag3[1:3] for at in sub_frag: safe_print(dict(at)) safe_print()